1. Field of the Invention
The present invention relates generally to a data processor which carries out operations between operands having different sizes, that is, having different bit lengths of data, and, in more detail, to a data processing apparatus capable of arithmetic and bit operations between different-sized operands under an addressing system wherein the most significant bit of data is stored in a low address in a memory and the least significant bit thereof is stored in a high order address in the memory.
2. Description of the Prior Art
Many debates have been made so far on whether the high order side of data is to be located on the high order address side or to be located on the low order address side when locating the data in a memory wherein addresses are formatted on a byte basis, and include numbers showing order or placement of bits in a byte.
A method wherein the high order side of data is located at high order addresses of a memory and the low order side of the data is located at low order addresses of the memory is called little endian, and a method wherein the high order side of data is located at low order addresses of a memory and the low order side of the data is located at high order addresses of the memory is called big endian.
In the recent data processors, generally addresses of a memory is put on a byte basis with one byte consisting of 8 bits. However, in the case of handling a bit map display or a bit field whose bit length is not integer a, bit address showing the bit position in the byte is also required in addition to the byte address, and the concept of little endian and big endian exists also for the bit address. The byte polarity and the bit polarity showing that the byte and the bit are little endian or big endian are not always required to be coincident. Detailed description is made in "On Holy Wars and a Plea for Peace," by D. Cohen, Computer, Vol. 14, No. 10, Oct., 1981, pp. 48-54 on whether the little endian is better or the big endian is better or which has been adopted by the conventional data processors.
The problem of little endian and big endian exists not only for addresses of bytes and bits in memory but also exists for byte and bit positions in a register.
FIG. 1 shows an example wherein for storing data aligned with low order address side as same as the case of storing in memory, for the case where data whose byte length is shorter than the byte length of a register is stored in the register in a data processor whose both the byte polarity and the bit polarity are big endian.
In this case, the bit address indicating the bit position is the same irrespective of the data size in the register, but in the case where an arithmetic operation such as addition between binary number data having different data sizes stored in two registers is executed, a problem occurs because the least significant bits of both data are not coincident. In the arithmetic an operation, operation is required to be executed to make with the least significant bits of both data coincident, and in this case, the operation of arithmetically shifting the data having a shorter size in the right direction must be executed after direction.
When hardware executing this arithmetic shift is employed for a register input-output unit and an ALU input-out unit, a problem occurs the data processor requires more hardware and becomes larger. Also, there is another problem that the operation speed is lowered when an operation is executed by machine instructions or microprograms.
As shown in FIG. 2, the MC68000 Series microprocessor manufactured by Motorola, the U.S. avoids this problem by setting the byte polarity to big endian and the bit polarity to little endian. However, in this case, since the bit polarity differs from the byte polarity, it is required to reverse the order of address calculation of data when handling byte strings and bit string, and therefore there exists a problem that the load in designing software is increased.
By setting both the byte polarity and the bit polarity to little endian, the problem in the operation between different-sized operands is eliminated, but the problem peculiar to the little endian format when in handling BCD (Binary-Coded Decimal) numbers or string data remains. The problem peculiar to the little endian is detailed in the above-mentioned paper by D. Cohen.
Also, in the case where data processors having different byte polarities or different bit polarities are incorporated into the same system, a problem occurs that a linking bus between these processors is complicated. In addition, an example of linking data processors having different byte polarities or bit polarities is described in "Data Format and Bus Compatibility in Multiprocessors" by H. Kirrman," IEEE Micro, August 1983, pp. 32-47.